home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The 640 MEG Shareware Studio 2
/
The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO
/
pascal
/
tpb4_src.zip
/
MISC.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1988-09-13
|
7KB
|
268 lines
{ TPBoard 4.2 Copyright (c) 1987,88 by Jon Schneider & Rick Petersen
Portions Copyright (c) 1986,87 by Steve Fox and Les Archambault
Last modified :: 7-1-88 8:16 pm
}
{$R-} {Range checking off}
{$B-} {Boolean complete evaluation off}
{$S-} {Stack checking off}
{$I+} {I/O checking on}
{$N-} {No numeric coprocessor}
Unit Misc;
Interface
Uses
TpCrt, Dos, TPSTRING, Core1,
Core2, Globals, BinEd;
procedure MakeWindow;
procedure full_screen_edit(EditFile : StrStd; Mode : Char; var abort : Boolean);
{==========================================================================}
Implementation
procedure MakeWindow;
const
X1 = 11;
Y1 = 7;
X2 = 70;
Y2 = 16;
Frame_Color = $17;
Title_Color = $17;
var
i : Integer;
lt : Integer;
where : Integer;
tempstr : string;
OK : Boolean;
t : tad_array;
strtd : StrTAD;
begin
Window(11, 7, 70, 16);
TextBackground(1);
ClrScr;
Window(1, 1, 80, 25);
TextBackground(0);
FastWrite('╒', Y1, X1, Frame_Color);
tempstr := '';
for i := (X1+1) to (X2-1) do
tempstr := tempstr+'═';
GetTAD(t);
strtd := FormTAD(t);
if Pos(' ', strtd) > 1 then
Delete(strtd, Pos(' ', strtd), 1);
lt := Length(tempstr);
where := (lt-Length(strtd)) div 2;
FastWrite(tempstr, Y1, X1+1, Frame_Color);
FastWrite(strtd, Y1, X1+where, $4E);
FastWrite('╕', Y1, X2, Frame_Color);
for i := (Y1+1) to (Y2-1) do
begin
FastWrite('│', i, X1, Frame_Color);
FastWrite('│', i, X2, Frame_Color);
end;
FastWrite('╘', Y2, X1, Frame_Color);
tempstr := '';
for i := (X1+1) to (X2-1) do
tempstr := tempstr+'═';
FastWrite(tempstr, Y2, X1+1, Frame_Color);
FastWrite('╛', Y2, X2, Frame_Color);
{$I-}
Seek(logr_file, 0); {$I+}
OK := (IoResult = 0);
if OK then
begin
{$I-}
Read(logr_file, logr_rec); {$I+}
OK := (IoResult = 0);
if OK then
FastWrite(' Last Caller Number..'+Long2Str(logr_rec.user),
9, 12, Title_Color);
end;
if auto_macro then
tempstr := ' Automatic Macro.....ENABLED at '+Long2Str(auto_macro_start)
+':00.'
else
tempstr := ' Automatic Macro.....OFF.';
FastWrite(tempstr, 10, 12, Title_Color);
if restrict300 then
tempstr := ' 300 Baud Callers....RESTRICTED '+Long2Str(start_restrict300)+
':00 - '+Long2Str(end_restrict300)+':00 Hours.'
else
tempstr := ' 300 Baud Callers....OK.';
FastWrite(tempstr, 11, 12, Title_Color);
if chat_ok then
tempstr := ' Chat Function.......ENABLED '+Long2Str(chatstart)+
':00 - '+Long2Str(chatend)+':00 Hours.'
else
tempstr := ' Chat Function.......OFF';
FastWrite(tempstr, 12, 12, Title_Color);
if limit_lines then
tempstr := ' Message Length......LIMITED to '+Long2Str(max_msg_lines)+' lines.'
else
tempstr := ' Message Length......NOT LIMITED.';
FastWrite(tempstr, 13, 12, Title_Color);
if extra_time_sw then
tempstr := ' Extra time..........'+Long2Str(extra_time_val)+
' Minutes given from '+Long2Str(ExtraTimeStart)+
':00 to '+Long2Str(ExtraTimeStop)+':00'
else
tempstr := ' Extra time..........NOT active.';
FastWrite(tempstr, 14, 12, Title_Color);
end;
procedure full_screen_edit(EditFile : StrStd; Mode : Char; var abort : Boolean);
type
BorderElements = (topleft, topright, botleft, botright, horiz, vert);
BorderChars = array[BorderElements] of Char;
const
Border : BorderChars = '┌┐└┘─│';
Title_Color = $17;
ExitCommands : array[0..6] of Char = (#2, ^K, ^Q, #2, #0, #68, #0);
var
EdData : EdCB;
BufPtr,
Routine : Pointer;
OK : Boolean;
Cx1, Cy1,
Cx2, Cy2 : Byte;
procedure DrawBox(Border : BorderChars; X1, Y1, X2, Y2 : Byte);
{-Draw a box around an editor window}
var
i : Word;
bar : string;
barlen : Byte absolute bar;
begin {DrawBox}
{Build horizontal bar}
barlen := 3+X2-X1;
FillChar(bar[1], barlen, Border[horiz]);
{Draw top bar}
bar[1] := Border[topleft];
bar[barlen] := Border[topright];
FastWrite(bar, Y1, X1, Title_Color);
{Draw bottom bar}
bar[1] := Border[botleft];
bar[barlen] := Border[botright];
FastWrite(bar, Y2+2, X1, Title_Color);
{Vertical bars}
for i := Succ(Y1) to Succ(Y2) do
begin
FastWrite(Border[vert], i, X1, Title_Color);
FastWrite(Border[vert], i, X2+2, Title_Color);
end;
end; {DrawBox}
procedure deinit; {Release heap and restore screen}
begin
ReleaseBinaryEditorHeap(EdData);
if OK then
begin
RestoreWindow(1, 1, CurrentWidth, Succ(CurrentHeight), True, BufPtr);
GotoXY(WhereX, WhereY-2)
end
else
ClrScr;
end;
begin
abort := False;
if Mode = 'W' then
begin
Cx1 := 5;
Cy1 := 2;
Cx2 := 78;
Cy2 := 20;
Routine := Addr(UserEventCheck);
end
else
begin
Cx1 := 3;
Cy1 := 2;
Cx2 := 79;
Cy2 := 20;
Routine := nil;
end;
while EditFile = '' do
EditFile := prompt('Name of file to edit', 80, 'ES');
if (InitBinaryEditor(EdData, Word(min(MaxAvail-1000, MaxFileSize)), Cx1, Cy1,
Cx2, Cy2, True, (EdOptInsert or EdOptTAB), '', ExitCommands, Routine) <> 0) then
begin
WriteLn(Com);
WriteLn(Com, 'Insufficient memory available.');
Exit;
end;
OK := SaveWindow(1, 1, CurrentWidth, Succ(CurrentHeight), True, BufPtr);
ClrScr;
DrawBox(Border, Cx1-2, Pred(Cy1), Pred(Cx2), Succ(Cy2));
if (ReadFileBinaryEditor(EdData, EditFile) > 1) then
begin
deinit;
WriteLn(Com);
WriteLn(Com, 'File too large to edit.');
Exit;
end;
ResetBinaryEditor(EdData);
case UseBinaryEditor(EdData, '') of
-1, 1 :
if ModifiedFileBinaryEditor(EdData) then
begin
if (SaveFileBinaryEditor(EdData, True) <> 0) then
begin
WriteLn(Com);
WriteLn(Com, 'File save failed.');
end;
end
else
abort := True;
0 :
begin
abort := True;
WriteLn(Com);
WriteLn(Com, 'File was not saved.');
end;
end;
deinit;
end;
end. {of MISC.PAS}